<?php
namespace app\api\controller;
use app\common\BaseController;
use app\api\model\MoneyLogs as MoneyLogsModel;
class MoneyLogs extends BaseController{    

    public function __construct(MoneyLogsModel $model){
        parent::__construct();
        $this->model = $model;
    }

    public function index(){
        $where=[];
        $params = $this->request->param(); 
        if(!empty($params['year_month'])){    
           //按年月查询
            if(!empty($params['year_month'])){               
                $where['month']=$params['year_month'];            
            }else{
                return '缺少搜索年月参数';
            }          
            //查询团号
            if(!empty($params['sn'])){
                $where['sn'] = ['like',"%{$params['sn']}%"];
            }
            //模糊查询           
            if(!empty($params['keyword'])){
                $where['category'] = ['like',"%{$params['keyword']}%"];               
            }
            $data = $this->model->with("operator")->where($where)->select();
            return $data;
        }else{
            return '缺少搜索年月参数';
        }  
        return array();  
    }
}